<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>BMI指数</title>
	</head>
	<body>
		<p>身高：（cm）</p>
		<input type="text" id="height" />
		<p>体重：（kg）</p>
		<input type="text" id="weight" />
		<P>
			<input type="button" value="BMI" onclick="bmi()"/>
		</P>
		<div id="result"></div>
		<script>
			function bmi(){
				var height=document.getElementById("height");
				var weight=document.getElementById("weight");
				var result=document.getElementById("result");
				var  h=height.value/100;
				var  w=weight.value;
				var  bmi=(w/(h*h)).toFixed(2);
				
				var s="您的BMI值是："+bmi;
				if (bmi<18.5) {
					s+="过轻";
				} else if (bmi<24) {
					s+="正常";
				} else if (bmi<27) {
					s+="肥胖";
				} else{
					s+="非常肥胖";
				}
				result.innerHTML=s;
			}
		</script>
	</body>
</html>
                                                                                               